/**
 * 环境配置
 */
import { name } from '../../package.json'
interface ConfigItem {
  BASE_URL: string
  MOCK_BASE_URL: string
}
type EnvConfigType = Record<ViteEnv, ConfigItem>

const env = import.meta.env.VITE_ENV || 'production'
const mockUrl = 'https://mock.com'

const envConfig: EnvConfigType = {
  development: {
    BASE_URL: 'https://dev.com',
    MOCK_BASE_URL: mockUrl,
  },
  staging: {
    BASE_URL: 'https://test.com',
    MOCK_BASE_URL: mockUrl,
  },
  production: {
    BASE_URL: 'https://prod.com',
    MOCK_BASE_URL: mockUrl,
  },
}

const resConfig = {
  env,
  isMock: false,
  localStorageNamespace: `${name}:${env}`,
  ...envConfig[env],
}

export default resConfig
